<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
<title>产品关联-商品关联</title>
<meta name="description" content="overview &amp; stats">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<!-- bootstrap & fontawesome -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/bootstrap.css">
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- page specific plugin styles -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/daterangepicker.min.css">

<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/jquery.gritter.min.css" />
<!-- text fonts -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/fonts.googleapis.com.css" />

<!-- text fonts -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/fonts.css">
<!-- ace styles -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/ace.min.css"
	class="ace-main-stylesheet" id="main-ace-style">
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/ace-skins.min.css">
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/ace-rtl.min.css">
<!-- ace settings handler -->
<script src="${request.contextPath}/static/assets/js/ace-extra.min.js"></script>
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/bootstrap-datepicker3.min.css">
<script src="${request.contextPath}/assets/js/jquery-2.1.4.min.js"></script>
<style>
@
keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
@
-moz-keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
@
-webkit-keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
@
-ms-keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
@
-o-keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
.ace-save-state {
	animation-duration: 10ms;
	-o-animation-duration: 10ms;
	-ms-animation-duration: 10ms;
	-moz-animation-duration: 10ms;
	-webkit-animation-duration: 10ms;
	animation-delay: 0s;
	-o-animation-delay: 0s;
	-ms-animation-delay: 0s;
	-moz-animation-delay: 0s;
	-webkit-animation-delay: 0s;
	animation-name: nodeInserted;
	-o-animation-name: nodeInserted;
	-ms-animation-name: nodeInserted;
	-moz-animation-name: nodeInserted;
	-webkit-animation-name: nodeInserted
}
</style>
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/bsie-paginator.css">
<style type="text/css">
#deleteRemind {
	width: 300px
}
</style>
</head>

<body class="skin-2" style="background-color: #FFF;">
	<div class="page-content" style="padding: 2px 2px 0px;">
		  <div class="tabbable">
			<div class="tab-content">
				<div id="manage" class="tab-pane active in">
					<!-- 筛选条件开始 -->
					<div class="row">
						<div class="col-sm-12">
							<div style="padding-right: 10px;">
								<span class="label label-xlg label-purple arrowed"  style="cursor: pointer;"  onclick="skip('${request.contextPath}/datashow/inputProduct?page=<#if prodPageNum??>${prodPageNum}<#else>1</#if>&companyCode=${companyCode!}&businessCode=${businessCode!}');">返回</span>
								<span class="label label-xlg label-pink arrowed-right"  style="cursor: pointer;"  data-toggle="modal" data-target="#myModal"  onclick="newInputCommodity();">新增</span>
							</div>
							<div class="widget-box">
								<div class="widget-header">
									<h4 class="widget-title lighter">
										<i class="ace-icon fa"></i>${inputCommodityVO.sceneryName!}(${inputCommodityVO.productId!})
									</h4>
									</div>
								<form class="form-inline" id="searchForm" method="post"
										action="${request.contextPath}/datashow/inputCommodity?productId=${inputCommodityVO.productId!}&sceneryName=${inputCommodityVO.sceneryName!}&companyCode=${companyCode!}&prodPageNum=${prodPageNum!}&businessCode=${businessCode!}">
										<input type="hidden" id="_csrf" name="${_csrf.parameterName}"
											value="${_csrf.token}" />
							   </form>
						</div>
					</div>
					<!-- 筛选条件结束 -->
				    <!-- tab开始 -->
					 <div class="col-xs-12"  id="codeList">
							<input type="hidden" id="_csrf" name="${_csrf.parameterName}"
								value="${_csrf.token}" /> 
							<input id="productId" name="productId" value="${inputCommodityVO.productId!}" type="hidden"> 
							<input id="sceneryName" name="sceneryName"value="${inputCommodityVO.sceneryName!}" type="hidden">
							<table id="dynamic-table"
								class="table table-striped table-bordered table-hover dataTable no-footer"
								role="grid" aria-describedby="dynamic-table_info">
								<thead>
									<tr>
										<th>商品id</th>
										<th>商品名称</th>
										<th>商品类型</th>
										<#if businessCode==""||businessCode=="TICKET">
										<th>提前条件</th>
										<th>门市价</th>
										</#if>
										<th>退改条件</th>
										<th>商品价格</th>
										<th>优惠</th>
										<th>最近抓取时间</th>
										<th>任务编码</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody class="commInfo">
									<#if commList??&&commList?size&gt;0> <#list commList as
									comm>

									<tr class="${comm.id}">
										<!--<td>${comm_index + 1}</td>  -->
										<td class="tdCommodityId"><#if comm.commodity_id??>${comm.commodity_id!}<#elseif comm.commodityId??>${comm.commodityId}</#if></td>
										<td class="tdCommodityName"><#if comm.commodity_name??>${comm.commodity_name!}<#elseif comm.commodityName??>${comm.commodityName}</#if></td>
										<td class="tdCommodityType"><#if comm.commodity_type??>${comm.commodity_type!}<#elseif comm.commodityType??>${comm.commodityType}</#if></td>
										<#if businessCode==""||businessCode=="TICKET">
										<td class="tdSaleCond">${comm.sale_cond!}</td>
										<td class="tdRackRate">${comm.rack_rate!}</td>
										</#if>
										<td class="tdRefundCond"><#if comm.refund_cond??>${comm.refund_cond!}<#elseif comm.cancelRule??>${comm.cancelRule!}</#if></td>
										
										<td class="tdSalePrice"><#if comm.sale_price??>${comm.sale_price!}<#elseif comm.salePrice??>${comm.salePrice}</#if></td>
										<td class="tdPreferential">${comm.preferential!}</td>
										<td class="tdNewGrabTime"><#if comm.new_grab_time??>${comm.new_grab_time?string("yyyy-MM-dd")}<#elseif comm.updateTime??>${comm.updateTime?string("yyyy-MM-dd")}</#if></td>
										<td class="tdTaskId"><#if comm.task_id??>${comm.task_id!}<#elseif comm.taskId??>${comm.taskId}</#if></td>
										<td>
											<a class="green"
												onclick="updateInputCommodity(this);" role="button" data-toggle="modal" data-target="#myModal"> <i
													class="ace-icon fa fa-pencil bigger-150"></i>
											</a>
											<a class="red" onclick="deleteInputCommodity(this);"> <i
													class="ace-icon fa fa-trash-o bigger-130"></i>
											</a>
										</td>
									</tr>
									</#list> </#if>

								</tbody>
							</table>
							<#include "paginator.html">
						</div>
					 </div>
			    </div>
			</div>
		</div>
	</div>
	
	
	
	
	
	<!-- <div class="page-content">
		<div class="page-header">
			
			<h1>${inputCommodityVO.sceneryName!}(${inputCommodityVO.productId!})</h1>
			
			<div class="row"  style="float:right;padding-bottom:10px">
			  <form class="form-inline" id="searchForm" method="post"
										action="${request.contextPath}/datashow/inputCommodity?productId=${inputCommodityVO.productId!}&sceneryName=${inputCommodityVO.sceneryName!}&companyCode=${companyCode!}&prodPageNum=${prodPageNum!}">
										<input type="hidden" id="_csrf" name="${_csrf.parameterName}"
											value="${_csrf.token}" />
			  </form>
			<div class="col-xs-1 col-sm-1" style="width:100px;">
				<button type="button" class="btn btn-pink btn-sm"
					onclick="skip('${request.contextPath}/datashow/inputProduct?page=<#if prodPageNum??>${prodPageNum}<#else>1</#if>&companyCode=${companyCode!}');">
					<span class="ace-icon fa icon-on-right bigger-110"></span> 返回产品页
				</button>
			</div>
			 
			<div class="col-xs-1 col-sm-1" >
				<div class="dataTables_length" style="width:200px;padding-left:1100px">
					<button type="button" class="btn btn-pink btn-sm"
						onclick="skip('${request.contextPath}/datashow/inputProduct?page=<#if pageNum??>${pageNum}<#else>1</#if>');">
						<span class="ace-icon fa icon-on-right bigger-110"></span> 返回产品页
					</button>
				</div>
			</div>
			 
			<div class="col-sm-12" align="right" style="padding_left:100px">
				<button type="button" class="btn btn-pink btn-sm" data-toggle="modal" data-target="#myModal"
					onclick="newInputCommodity();">
					<span class="ace-icon fa icon-on-right bigger-110"></span> 新增
				</button>
			</div>
			<div class="col-xs-1 col-sm-1" style="width: 100px;" align="right">
				<button type="button" class="btn btn-pink btn-sm" data-toggle="modal" data-target="#myModal"
					onclick="newInputCommodity();">
					<span
						class="ace-icon fa icon-on-right bigger-110"></span>
					新增
				</button>
			</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-12">
				<div class="row">
					<div class="col-xs-12">
						
					</div>
				</div> -->
				
				<!-- 更新商品 -->
				<div class="row">
					<div class="col-xs-12">
						<button class="btn btn-info" data-toggle="modal" type="button"
							style="display: none;" id="updateProduct"
							data-target="#myModal"></button>
						<form id="updateCode" class="form-horizontal" role="form"
							method='post'>
							<input type="hidden" id="_csrf" name="${_csrf.parameterName}"
								value="${_csrf.token}" />
							<div class="modal fade" id="myModal" tabindex="-1"
								role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"
												aria-hidden="true">×</button>
											<h4 class="modal-title" id="myModalLabel">商品编辑</h4>
										</div>
										<div class="modal-body">

											<div class="space-4"></div>
											<div class="form-group">
												<div class="col-sm-10">
													<input type="hidden" name="id" id="commodityTableId" />
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">产品ID</label>

														<div class="col-sm-8">
															<input type="text"  name="productId" value="${inputCommodityVO.productId!}"
																placeholder="产品ID" class="form-control" readonly>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">商品ID</label>

														<div class="col-sm-8">
															<input type="text" id="commodityId" name="commodityId"
																placeholder="商品ID" class="form-control" readonly>
														</div>
														<div style='color:red' class='remind'>*</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">商品名称</label>

														<div class="col-sm-8">
															<input type="text" id="commodityName" name="commodityName"
																placeholder="商品名称" class="form-control">
														</div>
														<div style='color:red' class='remind'>*</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">商品类型</label>

														<div class="col-sm-8">
															<input type="text" id="commodityType" name="commodityType"
																placeholder="商品类型" class="form-control">
														</div>
													</div>
													<#if businessCode==""||businessCode=="TICKET">
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">提前条件</label>

														<div class="col-sm-8">
															<input type="text" id="saleCond" name="saleCond"
																placeholder="提前条件" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">门市价 </label>

														<div class="col-sm-8">
															<input type="text" id="rackRate" name="rackRate"
																placeholder="门市价" class="form-control">
														</div>
													</div>
													</#if>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">退改条件</label>

														<div class="col-sm-8">
															<input type="text" id="refundCond" name="refundCond"
																placeholder="退改条件" class="form-control">
														</div>
													</div>
													
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">销售价</label>

														<div class="col-sm-8">
															<input type="text" id="salePrice" name="salePrice"
																placeholder="销售价" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">优惠</label>

														<div class="col-sm-8">
															<input type="text" id="preferential" name="preferential"
																placeholder="优惠" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">最新抓取时间</label>

														<div class="col-sm-8">
															<input type="text" id="newGrabTime" name="newGrabTime"
																placeholder="最新抓取时间" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">任务编码</label>

														<div class="col-sm-8">
															<input type="text" id="taskId" name="taskId"
																placeholder="任务编码" class="form-control">
														</div>
													</div>
													
												</div>
											</div>
										</div>
										<div class="modal-footer">
											<button type="button" class="btn btn-pink btn-sm"
												data-dismiss="modal">关闭</button>
											<button type="button" class="btn btn-pink btn-sm"
												id="submitInputCommodityUpdate" data-dismiss="modal">
												提交</button>
										</div>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal -->
							</div>
						</form>
					</div>
				</div>
				
				
				<!-- 删除提醒 -->
				<div class="row">
					<div class="col-xs-12">
						<button class="btn btn-info" data-toggle="modal" type="button"
							style="display: none;" id="deleteForm" data-target="#deleteModal">
						</button>
						<div class="modal fade" id="deleteModal" tabindex="-1"
							role="dialog" aria-labelledby="deleteModalLabel"
							aria-hidden="true">
							<input type="hidden" id="relCommodityId" name="relCommodityId" />
							<input type="hidden" id="delCommodityId" name="delCommodityId" />
							<input type="hidden" id="delCompanyCode" name="delCompanyCode" />
							<div class="modal-dialog link" id="deleteRemind">
								<div class="modal-content">
									<div class="modal-header" style="height: 20px">
										<button type="button" class="close" data-dismiss="modal"
											aria-hidden="true" id='close1'
											style="height: 10px; line-height: 5px">
											<small>×</small>
										</button>
									</div>
									<div class="modal-body">
										<strong style="padding-left: 70px">是否确认删除关联？</strong>
									</div>
									<div class="modal-footer" style="height: 50px">
										<button type="button" class="btn btn-default"
											data-dismiss="modal" style="height: 30px; line-height: 10px">
											取消</button>
										<button type="button" class="btn btn-primary"
											data-dismiss="modal" style="height: 30px; line-height: 10px"
											id="confirmDelete">确定</button>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
	<input type="hidden" id="productlistcontext"
		value="${request.contextPath}" />
	<input type="hidden" id="companyCode" value="${companyCode!}"/>
	<input type="hidden" id="businessCode"value="${businessCode!}">
	<script type="text/javascript">
		if ('ontouchstart' in document.documentElement)
			document
					.write("<script src='${request.contextPath}/static/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>
	<script src="${request.contextPath}/static/assets/js/bootstrap.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/jquery-ui.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/bootbox.js"></script>
	<script src="${request.contextPath}/static/assets/js/spin.js"></script>
	<!-- ace scripts -->
	<script
		src="${request.contextPath}/static/assets/js/ace-elements.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/ace.min.js"></script>
	<!-- validator scripts -->
	<script
		src="${request.contextPath}/static/assets/js/bootstrapValidator.min.js"></script>
	<!-- user scripts -->
	<script src="${request.contextPath}/static/assets/js/user/base.js"></script>
	<script type="text/javascript">
		var productlistcontext = $("#productlistcontext").val();
		
		var updateInputCommodity = function(obj) {
			$("input[name=newGrabTime]").datepicker({
				dateFormat : "yy-mm-dd",
				autoclose : true
			});
			$("#newGrabTime").removeAttr("readonly");
			companyCode=$("#companyCode").val();
			productId=$("#productId").val();
			cid=$(obj).parents("tr").attr("class");
			commodityId=$(obj).parents("tr").find(".tdCommodityId").text().trim();
			commodityName=$(obj).parents("tr").find(".tdCommodityName").text().trim();
			commodityType=$(obj).parents("tr").find(".tdCommodityType").text().trim();
			saleCond=$(obj).parents("tr").find(".tdSaleCond").text().trim();
			refundCond=$(obj).parents("tr").find(".tdRefundCond").text().trim();
			rackRate=$(obj).parents("tr").find(".tdRackRate").text().trim();
			salePrice=$(obj).parents("tr").find(".tdSalePrice").text().trim();
			preferential=$(obj).parents("tr").find(".tdPreferential").text().trim();
			newGrabTime=$(obj).parents("tr").find(".tdNewGrabTime").text().trim();
			taskId=$(obj).parents("tr").find(".tdTaskId").text().trim();
			$("#commodityTableId").val(cid);
			$("#commodityId").val(commodityId);
			$("#commodityName").val(commodityName);
			$("#commodityType").val(commodityType);
			$("#saleCond").val(saleCond);
			$("#refundCond").val(refundCond);
			$("#rackRate").val(rackRate);
			$("#salePrice").val(salePrice);
			$("#preferential").val(preferential);
			$("#newGrabTime").val(newGrabTime);
			$("#taskId").val(taskId);
			$("#commodityId").attr("readonly","true");
		};
		
		$("#submitInputCommodityUpdate").click(function(){
			companyCode=$("#companyCode").val();
			productId=$("#productId").val();
			$.ajax({
				url : productlistcontext + '/datashow/updateInputCommodity',
				type : "GET",
				data : {
					companyCode : companyCode,
					productId : productId,
					id:$("#commodityTableId").val(),
					commodityId : $("#commodityId").val(),
					commodityName:$("#commodityName").val(),
					commodityType:$("#commodityType").val(),
					saleCond:$("#saleCond").val(),
					refundCond:$("#refundCond").val(),
					rackRate:$("#rackRate").val(),
					salePrice:$("#salePrice").val(),
					preferential:$("#preferential").val(),
					newGrabTime:$("#newGrabTime").val(),
					taskId:$("#taskId").val(),
					businessCode:$("#businessCode").val()
				},
				success : function(data) {
					if(data.sessionStatus==540){//异步请求session过期状态
						window.location.href=productlistcontext+"/login";
						return;	
					//location.href="show_product?prodId="+prod_id+"&sceneryName="+tdSceneryName+"&pageNum="+$("#pageNum").val();
					}else{
						location.reload();
					}
					
				}
				
			});
		})
		
		var newInputCommodity=function(){
			$("#commodityTableId").val("");
			$("#commodityId").val("");
			$("#commodityName").val("");
			$("#commodityType").val("");
			$("#saleCond").val("");
			$("#refundCond").val("");
			$("#rackRate").val("");
			$("#salePrice").val("");
			$("#preferential").val("");
			$("#newGrabTime").val("");
			$("#taskId").val("");
			var mydate = new Date();
			year=mydate.getFullYear();
			month=mydate.getMonth()+1;
			day=mydate.getDate();
			$("#newGrabTime").val(year+"-"+month+"-"+day);
			$("#newGrabTime").attr("readonly","true");
			$("#commodityId").removeAttr("readonly");
		}
		var deleteInputCommodity = function(obj) {
			tid = $(obj).parents("tr").attr("class");
			companyCode = $("#companyCode").val();
			bootbox
					.confirm(
							"<strong style='font-size:15px;padding-left:150px'>是否确认删除？</strong>",
							function(result) {
								if (result) {
									$
											.ajax({
												url : productlistcontext
														+ '/datashow/deleteInputCommodity',
												type : "GET",
												data : {
													id : tid,
													companyCode : companyCode,
													businessCode:$("#businessCode").val()
												},
												success : function(data) {
													if(data.sessionStatus==540){//异步请求session过期状态
														window.location.href=productlistcontext+"/login";
														//location.href="show_product?prodId="+prod_id+"&sceneryName="+tdSceneryName+"&pageNum="+$("#pageNum").val();
														return;
													}else{
														location.reload();
													}
													//$(obj).parents("tr").remove();
													
												}
											});
								}
							}).attr("style","top:20%");
		};
	</script>

</body>
</html>